﻿@model DHQGHN.PM2.Models.DonViModel

@*@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")*@
@{
    SelectList slState = new SelectList(new[] {
        new SelectListItem { Value = "0", Text = "Chỉ báo cáo"},
        new SelectListItem { Value = "1", Text = "Chỉ giám sát"},
        new SelectListItem { Value = "2", Text = "Giám sát và báo cáo "}
    }, "Value", "Text", 0);

}

@using (Html.BeginForm("ActionSave", "DonVi", FormMethod.Post, new { @id = "frmDonVi" }))
{
    <div class="row">
        <div class="col-md-12">
            <fieldset id="fs1" class="fs_group1" style="border-style:hidden;">
                @Html.HiddenFor(m => m.DonViId)
                <div class="row" style="margin-top: 5px;">
                    <div class="col-md-3" style="">@Html.Label("Quyền Giám sát: ", new { id = "lblCheck", @class = "" })</div>
                    @*<div class="col-md-2" style="">@Html.CheckBox("CoQuyenGiamSat")</div>*@
                    <div class="col-md-9" style="">
                        @Html.DropDownList("IntCoQuyenGiamSat", slState, null, new { @class = "form-control input-sm" })
                    </div>
                </div>
                <div class="row" style="margin-top: 5px;">
                    <div class="col-md-3">
                        @Html.LabelFor(mode => mode.MaDonVi, new { @class = "", style = "" })
                        <font size="3" color="red" style="display:inline;" class="pm2-hidden">*</font>
                    </div>
                    <div class="col-md-3">
                        @Html.TextBoxFor(m => m.MaDonVi, new { @class = "form-control", style = "" })
                        <span style="color: red;">
                            @Html.ValidationMessageFor(m => m.MaDonVi)
                        </span>
                    </div>
                    <div class="col-md-3">
                        @Html.LabelFor(mode => mode.TenVietTat, new { @class = "", style = "" })
                        <font size="3" color="red" style="display:inline;" class="pm2-hidden">*</font>
                    </div>
                    <div class="col-md-3">
                        @Html.TextBoxFor(m => m.TenVietTat, new { @class = "form-control", style = "" })
                        <span style="color: red;">
                            @Html.ValidationMessageFor(m => m.TenVietTat)
                        </span>
                    </div>
                </div>
                <div class="row" style="margin-top: 5px;">
                    <div class="col-md-3">
                        @Html.LabelFor(m => m.TenDonVi, new { @class = "text-center", style = "" })
                        <font size="3" color="red" style="display:inline;" class="pm2-hidden">*</font>
                    </div>
                    <div class="col-md-9">
                        @Html.TextBoxFor(m => m.TenDonVi, new { @class = "form-control  ", @autofocus = "autofocus", style = "", @maxlength = 50 })
                        <span style="color: red;">
                            @Html.ValidationMessageFor(m => m.TenDonVi)
                        </span>
                    </div>
                </div>
                <div class="row" style="margin-top:5px;">
                    <div class="col-md-3">
                        <h5>@Html.LabelFor(m => m.GhiChu, new { @class = "text-center", style = "" })</h5>
                        <font size="3" style="display: inline; vertical-align: top; visibility:hidden;">*</font>
                    </div>
                    <div class="col-md-9">
                        @*@Html.TextAreaFor(m => m.GhiChu, new { @class = "form-control", @rows = 3, style = "" })*@
                        @Html.TextArea("GhiChu", new { @class = "form-control", @rows = 3, style = "" })
                    </div>
                </div>

            </fieldset>
        </div>
    </div>
}

@Scripts.Render("~/bundles/jqueryval")

<script>
    @functions{
            public string GetAntiForgeryToken()
            {
                string cookieToken, formToken;
                AntiForgery.GetTokens(null, out cookieToken, out formToken);
                return cookieToken + "," + formToken;
            }
        }
</script>
<script>

    var $form = $("#certification-form");
    function save() {
        var result = false;
        if ($form.valid()) {
            $.ajax({
                type: "POST",
                url: $form.attr('action'),
                data: $form.serialize(),
                dataType: '',//chú ý là form đặc biệt thì phải điền trường này
                async: false,
                headers: {
                    'VerificationToken': '@GetAntiForgeryToken()'
                },
                success: function (response) {
                    if (response != null && response.status == 200) {
                        window.notice(response.result, window.notice_success);
                        OnCriteria(0);
                        result = true;
                    } else {
                        window.notice(response.result, window.notice_error);
                    }
                }
            });
        }
        return result;
    }
</script>